Skip to content

Explain the data folders bundlers don't copy - #5

Merged
alekswebnet merged 2 commits into
mainfrom
docs/pdfjs-viewer-data-folders
Nov 1, 2026
Merged

alekswebnet merged 2 commits into
mainfrom
docs/pdfjs-viewer-data-folders

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Pairs with missing-elements/pdfjs-viewer#70, released in pdfjs-viewer 4.4.2. The copy script resolves @missing-elements/pdfjs-viewer/package.json, which 4.4.2 exports, and the Next.js claims depend on its fixes.

  • Bundlers and assets-base: names Next.js (webpack or Turbopack) next to Vite and webpack 5. It lists what breaks without the PDF.js data folders, and gives a postinstall script that copies dist into public/pdfjs-viewer/ for assets-base. For CI that skips install scripts, it shows how to run the copy from build instead.
  • CMaps, fonts and other resources: CCITT images need the WASM decoders too, and the bundled-apps sentence links to the recipe.
  • Bumps @missing-elements/pdfjs-viewer to 4.4.2, so the live preview and the version numbers come from that release.

Validation:

  • pnpm build (Eleventy) passes, and #bundlers-and-assets-base resolves.
  • The built site's playground runs 4.4.2 in Chromium. The viewer is styled, opens the sample PDF, and logs no errors.
  • The script's import.meta.resolve('@missing-elements/pdfjs-viewer/package.json') resolves against the published 4.4.2.
  • I ran the script as postinstall in Next.js 16.4.3 (Turbopack and webpack) and Vite 8.3.5 builds with assets-base="/pdfjs-viewer/". With the copy, JBIG2, CCITT and JPEG 2000 scans, CJK text in a non-embedded font, PDF JavaScript and note icons all work. Without it, they all fail.

🤖 Generated with Claude Code

List what breaks without them in Vite, webpack 5 and Next.js builds, and give a postinstall script
that copies the package's dist folder for assets-base, with a variant for CI that skips install
scripts. CCITT images also need the WASM decoders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alekswebnet
alekswebnet marked this pull request as ready for review November 1, 2026 12:40
@alekswebnet
alekswebnet merged commit a5e7192 into main Nov 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant